bash arrays - what is difference between ${#array_name[*]} and ${#array_name[@]}

Posted by Ravi on Stack Overflow See other posts from Stack Overflow or by Ravi
Published on 2010-06-17T09:36:46Z Indexed on 2010/06/17 9:43 UTC
Read the original article Hit count: 349

Filed under:
|
bash-3.00$ cat arr.bash  
#!/bin/bash  

declare -a myarray  
myarray[2]="two"  
myarray[5]="five"  

echo ${#myarray[*]}  
echo ${#myarray[@]}  

bash-3.00$ ./arr.bash  
2  
2

both are giving number of elements of array. So what is difference between the two?

© Stack Overflow or respective owner

Related posts about arrays

Related posts about bash